home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / ctutor2.zip / IFELSE.C < prev    next >
C/C++ Source or Header  |  1987-07-04  |  483b  |  20 lines

  1.                                          /* Chapter 3 - Program 4 */
  2. /* This is an example of the if and the if-else statements */
  3.  
  4. main()
  5. {
  6. int data;
  7.  
  8.    for(data = 0;data < 10;data = data + 1) {
  9.  
  10.       if (data == 2)
  11.          printf("Data is now equal to %d\n",data);
  12.  
  13.       if (data < 5)
  14.          printf("Data is now %d, which is less than 5\n",data);
  15.       else
  16.          printf("Data is now %d, which is greater than 4\n",data);
  17.  
  18.    }  /* end of for loop */
  19. }
  20.